﻿using System.Web.Mvc;
using Nop.Web.Framework.Security;
using Nop.Services.Orders;
using Nop.Services.Catalog;
using Nop.Web.Models.Catalog;
using Nop.Core.Domain.Catalog;
using System.Collections.Generic;
using System.Linq;
using Nop.Services.Common;

namespace Nop.Web.Controllers
{
    public partial class HomeController : BaseNopController
    {
        #region Fields
        private readonly IProductService _productService;
        private readonly IMenuService _menuService;
        #endregion

        #region Constructors
        public HomeController(IProductService productService, IMenuService menuService)
        {
            this._productService = productService;
            this._menuService = menuService;
        }
        #endregion


        

        [NopHttpsRequirement(SslRequirement.No)]
        public ActionResult Index()
        {
            return View();
        }

        [NopHttpsRequirement(SslRequirement.No)]
        public ActionResult Search(string strWhere)
        {
            //查询条件
            ViewBag.strWhere = strWhere;
            var model = new List<ProductOverviewModel>();
            var products = _productService.GetListByFunc(p => p.Name.Contains(strWhere));
            int foodId = 1;//默认为1
            if (products.FirstOrDefault() != null)
            {
                foodId = products.FirstOrDefault().Id;
            }

            ViewBag.foodId = foodId;
            return View();
        }


        [NopHttpsRequirement(SslRequirement.No)]
        public ActionResult Login()
        {
            return View();
        }

        [NopHttpsRequirement(SslRequirement.No)]
         public ActionResult MenuNavigation()
         {
             var menus = _menuService.GetAllMenu().ToList() ;

             //return View(menus);
             return View();
         }

        /// <summary>
        /// 关于我们
        /// </summary>
        /// <returns></returns>
        public ActionResult AboutUs()
        {
            return View();
        }
    }
}
